//
//  XFUser.m
//  SinaBlog_OC
//
//  Created by macs on 15/11/16.
//  Copyright © 2015年 BlackTail. All rights reserved.
//

#import "XFUser.h"

@implementation XFUser

+ (instancetype)userWithDict:(NSDictionary *)dict {

  XFUser *user = [[XFUser alloc] init];

  [user setValuesForKeysWithDictionary:dict];

  return user;
}

- (void)setValue:(id)value forKey:(NSString *)key {

  if ([key isEqualToString:@"id"]) {
    [super setValue:value forKey:@"ids"];
    return;
  }

  [super setValue:value forKey:key];
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
  //过滤
}

- (NSURL *)headImageUrl {

  return [NSURL URLWithString:self.profile_image_url];
}

- (UIImage *)mbrankImage {

  if (self.mbrank > 0 && self.mbrank < 7) {

    return [UIImage
        imageNamed:[NSString stringWithFormat:@"common_icon_membership_level%d",
                                              self.mbrank]];
  }
  return nil;
}

- (UIImage *)verifiedImage {
  switch (self.verified_type) {
  case 0:
    return [UIImage imageNamed:@"avatar_vip"];
    break;
  case 2:
  case 3:
  case 5:
    return [UIImage imageNamed:@"avatar_enterprise_vip"];
    break;
  case 220:
    return [UIImage imageNamed:@"avatar_grassroot"];
    break;
  default:
    return nil;
    break;
  }
}

@end
